import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-20
 * Time: 13:31
 */
public class Test68 {
//    输入：num = [3,4,5,1,2]
//    输出：1
//    解释：原数组为 [1,2,3,4,5] ，旋转 3 次得到输入数组。
    public static int findMin(int[] num) {
        int n = num.length;
        int left = 0, right = n-1;
        // 二段性
        int x = num[0];
        while(left < right) {
            int mid = left + (right - left) / 2;
            if(num[mid] >= x) {
                left = mid+1;
            }else {
                right = mid;
            }
        }
        if(x < num[n-1]) {
            return x;
        }
        return num[left];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int ret = findMin(num);
        System.out.println(ret);
    }
}
